package com.graduation.books_borrow.Controller;

import com.graduation.books_borrow.Service.UserService;
import com.graduation.books_borrow.entity.User;
import com.graduation.books_borrow.ret.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("userRegister")
    public R userRegister(@RequestBody Map<String, String> map) {
        String username = map.get("username");
        String password = map.get("password");
        User user = new User(username, password);

        return userService.userRegister(user);
    }

    @PostMapping("userLogin")
    public R userLogin(@RequestBody Map<String, String> map) {
        String username = map.get("username");
        String password = map.get("password");
        User user = new User(username, password);

        return userService.userLogin(user);
    }





}
